/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trefliq.persistence.entity;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author Adam Gojdas
 */
public class InitDBData {
        private static Connection _con = null;
        private static Statement _st = null;

        private static String url = "jdbc:derby://localhost:1527/sample";
        private static String user = "app";
        private static String password = "app";
   
    public InitDBData() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
          _con = DriverManager.getConnection(url, user, password);

          _con.setAutoCommit(false);
          _st = _con.createStatement();
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
        try { 
                if (_st != null) {
                    _st.close();
                }
                if (_con != null) {
                    _con.close();
                }
            } catch (SQLException ex) {
                Logger lgr = Logger.getLogger(InitDBData.class.getName());
                lgr.log(Level.WARNING, ex.getMessage(), ex);
            }
    }
    
    @Before
    public void initTransaction() {
//        _tx = _em.getTransaction();
    }
        
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    
    /**
     * Test of crud routines for Credit.
     */
    @Test
    public void SetupData() {
        System.out.println("SetupData");
        ClearTables();
        InsertMEDIA();
        InsertRATING();
        InsertGENRE();
        InsertCREDITINMOVIE();
        InsertMOVIE();
        InsertSHOWBIZPEOPLE();
        //InsertMOVIEGENRE(); entity not created yet
        InsertMOVIECREDIT();
        InsertPERMISSION();
        InsertPERSON();
        InsertINVENTORY();
        InsertCREDENTIAL();   
//        InsertEMPLOYEE();
//        InsertCUSTOMERS();
        InsertACCOUNT();   
    }
    
    /**
      Clear all the tables to be ready for inserts.
     */    
    private void ClearTables() {
         try {
          
            _st.addBatch("DELETE FROM ACCOUNT");
//            _st.addBatch("DELETE FROM CUSTOMERS");
//            _st.addBatch("DELETE FROM EMPLOYEE");
            _st.addBatch("DELETE FROM CREDENTIAL");
            _st.addBatch("DELETE FROM INVENTORY");
            _st.addBatch("DELETE FROM PERSON");
            _st.addBatch("DELETE FROM PERMISSION");
            _st.addBatch("DELETE FROM MOVIECREDIT");
//            _st.addBatch("DELETE FROM MOVIEGENRE");
            _st.addBatch("DELETE FROM SHOWBIZPEOPLE");
            _st.addBatch("DELETE FROM MOVIE");
            _st.addBatch("DELETE FROM CREDIT");
            _st.addBatch("DELETE FROM GENRE");
            _st.addBatch("DELETE FROM RATING");
            _st.addBatch("DELETE FROM MEDIA");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The delete for ClearTables failed.");
        }
    }

    /**
      Create some records, for table MEDIA.
     */    
    private void InsertMEDIA() {
         try {
          
          //MEDIA is an enum so it appears VHS,VCD,BRD,DVD would be 1,2,3,4

          _st.addBatch("INSERT INTO APP.MEDIA (MT) VALUES (1)");
          _st.addBatch("INSERT INTO APP.MEDIA (MT) VALUES (2)");
          _st.addBatch("INSERT INTO APP.MEDIA (MT) VALUES (3)");
          _st.addBatch("INSERT INTO APP.MEDIA (MT) VALUES (4)");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertMEDIA failed.");
        }
    }

     /**
      Create some records, for table RATING.
     */    
    private void InsertRATING() {
         try {
          
          //RATING is an enum so it appears NULL, G, PG, PG13, R, X, NC17, NR would be 1,2,3,4

            _st.addBatch("INSERT INTO APP.RATING (CODE,CODEVALUE,DESCRIPTION) VALUES (1,'G','General Audiences')");
            _st.addBatch("INSERT INTO APP.RATING (CODE,CODEVALUE,DESCRIPTION) VALUES (2,'PG','Parental Guidance Suggested')");
            _st.addBatch("INSERT INTO APP.RATING (CODE,CODEVALUE,DESCRIPTION) VALUES (3,'PG13','Parents Strongly Cautioned')");
            _st.addBatch("INSERT INTO APP.RATING (CODE,CODEVALUE,DESCRIPTION) VALUES (4,'R','Restricted')");
            _st.addBatch("INSERT INTO APP.RATING (CODE,CODEVALUE,DESCRIPTION) VALUES (5,'X','No Children 17 And Under Admitted')");
            _st.addBatch("INSERT INTO APP.RATING (CODE,CODEVALUE,DESCRIPTION) VALUES (6,'NC17','No Children 17 And Under Admitted')");
            _st.addBatch("INSERT INTO APP.RATING (CODE,CODEVALUE,DESCRIPTION) VALUES (7,'NR','No Rating')");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertRATING failed.");
        }
    }

     /**
      Create some records, for table GENRE.
     */    
    private void InsertGENRE() {
         try {
          
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (1,'Comedy')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (2,'Action')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (3,'Western')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (4,'Adventure')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (5,'Drama')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (6,'Horror')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (7,'Family')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (8,'War')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (9,'Sci-Fi')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (10,'Historical')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (11,'Crime')");
            _st.addBatch("INSERT INTO APP.GENRE (ID,GENREVALUE) VALUES (12,'Kids')");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertGENRE failed.");

        }
    }

     /**
      Create some records, for table CREDITINMOVIE.
     */    
    private void InsertCREDITINMOVIE() {
         try {
          
          //CREDITINMOVIE is an enum so it appears NULL, G, PG, PG13, R, X, NC17, NR would be 1,2,3,4

            _st.addBatch("INSERT INTO APP.CREDIT (ID,CREDITINMOVIE) VALUES (1,'STAR')");
            _st.addBatch("INSERT INTO APP.CREDIT (ID,CREDITINMOVIE) VALUES (2,'DIRECTOR')");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertCREDITINMOVIE failed.");

        }
    }
    /**
    Create some records, for table MOVIE.
    */    
    private void InsertMOVIE() {
         try {

            _st.addBatch("INSERT INTO APP.MOVIE (ID,TITLE,DESCRIPTION,RATING,RELEASE) VALUES (1,'The Dark Knight',' Batman, Gordon and Harvey Dent are forced to deal with the chaos unleashed by a terrorist mastermind known only as the Joker, as he drives each of them to their limits. ',3,'1/1/2008')");
            _st.addBatch("INSERT INTO APP.MOVIE (ID,TITLE,DESCRIPTION,RATING,RELEASE) VALUES (2,'The Lord of the Rings: The Return of the King','The former Fellowship of the Ring prepare for the final battle for Middle Earth, while Frodo & Sam approach Mount Doom to destroy the One Ring. ',3,'1/1/2003')");
            _st.addBatch("INSERT INTO APP.MOVIE (ID,TITLE,DESCRIPTION,RATING,RELEASE) VALUES (3,'WALL·E','In the distant future, a small waste collecting robot inadvertently embarks on a space journey that will ultimately decide the fate of mankind.',1,'1/1/2008')");
            _st.addBatch("INSERT INTO APP.MOVIE (ID,TITLE,DESCRIPTION,RATING,RELEASE) VALUES (4,'Gran Torino','Disgruntled Korean War vet Walt Kowalski sets out to reform his neighbor, a young Hmong teenager, who tried to steal Kowalski''s prized possession: his 1972 Gran Torino.',4,'1/1/2008')");
            _st.addBatch("INSERT INTO APP.MOVIE (ID,TITLE,DESCRIPTION,RATING,RELEASE) VALUES (5,'The Incredibles','A family of undercover superheroes, while trying to live the quiet suburban life, are forced into action to save the world. ',2,'1/1/2004')");
            _st.addBatch("INSERT INTO APP.MOVIE (ID,TITLE,DESCRIPTION,RATING,RELEASE) VALUES (6,'Grindhouse','Two full length feature horror movies written by Quentin Tarantino & Robert Rodriguez put together as a two film feature. Including fake movie trailers in between both movies. ',6,'1/1/2007')");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertMOVIE failed.");

        }
    }

    /**
    Create some records, for table SHOWBIZPEOPLE.
    */    
    private void InsertSHOWBIZPEOPLE() {
         try {
          
          //CREDITINMOVIE is an enum so it appears NULL, G, PG, PG13, R, X, NC17, NR would be 1,2,3,4

            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (1,'KURT','RUSSEL')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (2,'ROSE','MCGOWAN')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (3,'ROBERT','RODRIGUEZ')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (4,'CRAIG','NELSON')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (5,'HOLLY','HUNTER')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (6,'BRAD','BIRD')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (7,'CLINT','EASTWOOD')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (8,'BEN','BURT')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (9,'ELISSA','KNIGHT')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (10,'ANDREW','STANTON')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (11,'ELIJAH','WOOD')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (12,'VIGGO','MORTENSEN')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (13,'PETER','JACKSON')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (14,'CHRISTIAN','BALE')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (15,'HEATH','LEDGER')");
            _st.addBatch("INSERT INTO APP.SHOWBIZPEOPLE (ID,FNAME,LNAME) VALUES (16,'CHISTOPHER','NOLAN')");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertSHOWBIZPEOPLE failed.");

        }
    }

    /**
    Create some records, for table MOVIEGENRE.
    */    
    private void InsertMOVIEGENRE() {
         try {
          
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (1,2)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (1,11)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (2,2)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (2,4)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (2,5)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (3,4)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (3,7)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (4,5)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (5,2)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (5,4)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (5,7)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (5,12)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (6,2)");
            _st.addBatch("INSERT INTO APP.MOVIEGENRE (MOVIEID,GENREID) VALUES (6,6)");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertMOVIEGENRE failed.");

        }
    }
    
    /**
    Create some records, for table MOVIECREDIT.
    */    
    private void InsertMOVIECREDIT() {
         try {
          
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (1,1,2)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (1,14,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (1,15,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (2,11,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (2,12,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (2,13,2)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (3,8,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (3,9,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (3,10,2)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (4,7,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (4,7,2)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (5,4,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (5,5,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (5,6,2)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (6,1,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (6,2,1)");
            _st.addBatch("INSERT INTO APP.MOVIECREDIT (MOVIEID,SHOWBIZPEOPLEID,CREDITID) VALUES (6,3,2)");

          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertMOVIECREDIT failed.");

        }
    }

    /**
    Create some records, for table MOVIECREDIT.
    */    
    private void InsertPERMISSION() {
         try {
          
            _st.addBatch("INSERT INTO APP.PERMISSION (ID,USERNAME,SUPERUSER,CANEDITINV,CANEDITCUST,CANMANAGEORDERS) VALUES (1,'SUPERVISOR',1,1,1,1)");
            _st.addBatch("INSERT INTO APP.PERMISSION (ID,USERNAME,SUPERUSER,CANEDITINV,CANEDITCUST,CANMANAGEORDERS) VALUES (2,'MANAGER',0,1,1,1)");
            _st.addBatch("INSERT INTO APP.PERMISSION (ID,USERNAME,SUPERUSER,CANEDITINV,CANEDITCUST,CANMANAGEORDERS) VALUES (3,'SENIOR_CLERK',0,0,1,1)");
            _st.addBatch("INSERT INTO APP.PERMISSION (ID,USERNAME,SUPERUSER,CANEDITINV,CANEDITCUST,CANMANAGEORDERS) VALUES (4,'CLERK',0,0,0,1)");
            _st.addBatch("INSERT INTO APP.PERMISSION (ID,USERNAME,SUPERUSER,CANEDITINV,CANEDITCUST,CANMANAGEORDERS) VALUES (5,'TRAINEE',0,0,0,0)");
 
          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertPERMISSION failed.");

        }
    }
    
    /**
    Create some records, for table PERSON.
    */    
    private void InsertPERSON() {
         try {
          
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (1,'SUE','JONES','7089991234','111 MAIN','STE 222','CHICAGO','IL','60606','SUEJONES@GMAIL.COM')");
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (2,'RON','SMITH','6308881213','222 FIRST','P.O. BOX123','CHICAGO','IL','67432','RONSMITH@GMAIL.COM')");
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (3,'JILL','WELLS','7086751238','333 ELM',null,'NAPERVILLE','IL','60001','JILLWELLS@GMAIL.COM')");
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (4,'FRANK','CAINE','6307779876','444 PARK ST',null,'CICERO','IL','62310','FRANKCAINE@GMAIL.COM')");
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (5,'JENNY','FISK','7734585252','555 SECOND ST','STE 333','CHICAGO','IL','60526','JENNYFISK@GMAIL.COM')");
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (6,'BILL','BEANE','7738559512','123 MAIN ',null,'NAPERVILE','IL','60522','BILLBEANE@GMAIL.COM')");
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (7,'GRETTA','SWIT','6305459696','456 DOVER','APT 12','GENEVA','IL','62315','GRETTASWIT@GMAIL.COM')");
            _st.addBatch("INSERT INTO APP.PERSON (ID,FNAME,LNAME,PHONE,ADD1,ADD2,CITY,ST,ZIP,EMAIL) VALUES (8,'ISSAC','PELT','7734549142','789 POINT',null,'CHICAGO','IL','65312','ISSACPELT@GMAIL.COM')");
 
          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertPERSON failed.");

        }
    }
    /**
    Create some records, for table INVENTORY.
    */    
    private void InsertINVENTORY() {
         try {
          
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (1,1,20,1,20)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (2,1,10,2,10)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (3,1,5,3,5)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (4,1,25,4,25)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (5,2,20,1,20)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (6,2,10,2,10)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (7,2,5,3,5)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (8,2,25,4,25)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (9,3,20,1,20)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (10,3,10,2,10)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (11,3,5,3,5)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (12,3,25,4,25)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (13,4,20,1,20)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (14,4,10,2,10)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (15,4,5,3,5)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (16,4,25,4,25)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (17,5,20,1,20)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (18,5,10,2,10)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (19,5,5,3,5)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (20,5,25,4,25)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (21,6,20,1,20)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (22,6,10,2,10)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (23,6,5,3,5)");
            _st.addBatch("INSERT INTO APP.INVENTORY (ID,MOVIEID,ITEMCOUNT,MEDIAID,ITEMSAVAILABLE) VALUES (24,6,25,4,25)");
 
          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertINVENTORY failed.");

        }
    }

    /**
    Create some records, for table CREDENTIAL.
    */    
    private void InsertCREDENTIAL() {
         try {
          
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (1,'SJONES','SJONES')");
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (2,'RSMITH','RSMITH')");
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (3,'JWELLS','JWELLS')");
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (4,'FCAINE','FCAINE')");
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (5,'JFISK','JFISK')");
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (6,'BBEANE','BBEANE')");
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (7,'GSWIT','GSWIT')");
            _st.addBatch("INSERT INTO APP.CREDENTIAL (ID,USERNAME,PASSWORD) VALUES (8,'IPELT','IPELT')");
 
          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertCREDENTIAL failed.");

        }
    }

    /**
    Create some records, for table EMPLOYEE.
    */    
    private void InsertEMPLOYEE() {
         try {
          
            _st.addBatch("INSERT INTO APP.EMPLOYEE (ID,ROLEID,PERSONID,CREDENTIALID) VALUES (1,1,1,1)");
            _st.addBatch("INSERT INTO APP.EMPLOYEE (ID,ROLEID,PERSONID,CREDENTIALID) VALUES (2,2,2,2)");
            _st.addBatch("INSERT INTO APP.EMPLOYEE (ID,ROLEID,PERSONID,CREDENTIALID) VALUES (3,3,3,3)");
            _st.addBatch("INSERT INTO APP.EMPLOYEE (ID,ROLEID,PERSONID,CREDENTIALID) VALUES (4,4,4,4)");
            _st.addBatch("INSERT INTO APP.EMPLOYEE (ID,ROLEID,PERSONID,CREDENTIALID) VALUES (5,5,5,5)");
 
          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertEMPLOYEE failed.");

        }
    }    
    
    /**
    Create some records, for table CUSTOMERS.
    */    
    private void InsertCUSTOMERS() {
         try {
          
            _st.addBatch("INSERT INTO APP.CUSTOMERS (ID,PERSONID,CREDENTIALID) VALUES (1,6,6))");
            _st.addBatch("INSERT INTO APP.CUSTOMERS (ID,PERSONID,CREDENTIALID) VALUES (2,7,7))");
            _st.addBatch("INSERT INTO APP.CUSTOMERS (ID,PERSONID,CREDENTIALID) VALUES (3,8,8))");
 
          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertEMPLOYEE failed.");

        }
    }    

    /**
    Create some records, for table ACCOUNT.
    */    
    private void InsertACCOUNT() {
         try {
          
            _st.addBatch("INSERT INTO APP.ACCOUNT (ID,CUSTOMERID,CREDITCARDNUMBER,STREETADDRESS,CITYADDRESS,STATEADDRESS,ZIPCODEADDRESS,ACTIVE) VALUES (1,1,'3333333333333333','CREDIT ST','CHICAGO','IL',60651,1)");
            _st.addBatch("INSERT INTO APP.ACCOUNT (ID,CUSTOMERID,CREDITCARDNUMBER,STREETADDRESS,CITYADDRESS,STATEADDRESS,ZIPCODEADDRESS,ACTIVE) VALUES (2,2,'4444444444444444','CREDIT AVE','CHICAGO','IL',60678,1)");
            _st.addBatch("INSERT INTO APP.ACCOUNT (ID,CUSTOMERID,CREDITCARDNUMBER,STREETADDRESS,CITYADDRESS,STATEADDRESS,ZIPCODEADDRESS,ACTIVE) VALUES (3,3,'5555555555555555','CREDIT CR','CHICAGO','IL',60332,1)"); 
          int counts[] = _st.executeBatch();

          _con.commit();

          System.out.println("Committed " + counts.length + " updates");

        } catch (SQLException ex) {

            if (_con != null) {
                try {
                    _con.rollback();
                } catch (SQLException ex1) {
                    Logger lgr = Logger.getLogger(InitDBData.class.getName());
                    lgr.log(Level.WARNING, ex1.getMessage(), ex1);
                }
            }

            Logger lgr = Logger.getLogger(InitDBData.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
            fail("The insert for InsertACCOUNT failed.");

        }
    }    
    
    
}
